'use strict';
module.exports = {
    store: {
        required: ['openid', 'location', 'city'],
        properties: {
            openid: { bsonType: 'string', description: '商家ID' },
            platform: { bsonType: 'string', description: '平台' },
            merchant: { bsonType: 'string', description: '商家名' },
            cityCode: { bsonType: 'string', description: '城市代码' },
            province: { bsonType: 'string', description: '省级' },
            city: { bsonType: 'string', description: '城市' },
            district: { bsonType: 'string', description: '区' },
            location: {
                bsonType: 'object', required: ['type', 'coordinates'],
                properties: {
                    type: { bsonType: 'string', description: '坐标位置' },
                    coordinates: { bsonType: 'array', description: '坐标位置' }
                }
            },
            reviewCount: { bsonType: 'int', description: '评论数' },
            averageCost: { bsonType: 'int', description: '平均消费' },
            businessStatus: { bsonType: 'int', description: '营业状态' },
            rating: { bsonType: 'int', description: '评分' },
            businessHours: { bsonType: 'string', description: '营业时间' },
            address: { bsonType: 'string', description: '地址' },
            businessDistrict: { bsonType: 'string', description: '商圈' },
            merchantImage: { bsonType: 'string', description: '店面图片' },
            mainCategory: { bsonType: 'string', description: '一级分类' },
            middleCategory: { bsonType: 'string', description: '二级分类' },
            middleCategoryId: { bsonType: 'int', description: '二级分类id' },
            subCategory: { bsonType: 'string', description: '三级分类' },
            brand: { bsonType: 'string', description: '品牌' },
            phone: { bsonType: 'string', description: '电话号码' },
            collectionTime: { bsonType: 'string', description: '平台收集记录' },
            createTime: { bsonType: 'string', description: '平台创建时间' },
            recommendedDishes: { bsonType: 'array', description: '推荐菜' },
            smallRating: { bsonType: 'string', description: '分级评价' },
        },
        indexes: [ // 添加索引定义
            { key: { openid: 1 }, options: { unique: true } },
            { key: { location: '2dsphere' } },
            { key: { province: 1, city: 1, district: 1 } } // 新增的复合索引
        ]
    },
    food: {
        required: ['value', 'name', 'meal'],
        properties: {
            name: { bsonType: 'string', description: '菜名' },
            value: { bsonType: 'string', description: '营养价值' },
            meal: { bsonType: 'array', description: '三餐' },
        },
        indexes: [ // 添加索引定义
            { key: { name: 1 }, options: { unique: true } },
        ]
    },
};